<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>回复电影评论</title>
    <%- include common %>
</head>

<body>
    <%- include("head",{title:"mlist",username})%>
    <div class="container container-fluid">
        <div class="row">
            <div class="col-md-6 col-sm-6 col-lg-6">
                <h2 class="text-danger  text-center">评论信息</h2>
                <div style="margin-top:20px;border-bottom:1px dashed blue;padding-bottom:20px">
                    <div style="display: flex;justify-content: space-between;">
                        <p> 作者: <%- result.author %></p>
                        <p class=" text-warning"> 时间 : <%- result.time %> </p>
                    </div>
                    <div style="display: flex;justify-content: space-between;">
                        <h5 class="pull-right text-primary ">标题: <%- result.title %> </h5>
                        <p>评论电影- <%- result.movie.title %> </p>
                    </div>
                    <div class="thumbnail" id="thumbnail" style="min-height:50px;">
                        <p>点此展开电影详情</p>
                        <div class="shiyan" style="display: none;">
                            <img src="<%- result.movie.images.large.replace(/img7/,'img3') %>" alt=""
                                style="height:400px;width:100%">
                            <div>
                                <h4 class="pull-right"> <%- result.movie.year %> </h4>
                                <p class="text-success">评分 : <%- result.movie.rating.average %></p>
                                <p class="text-primary">分类 : <%- result.movie.genres %></p>
                                <p class="text-primary">导演 : <%- result.movie.directors[0].name %></p>
                                <p class="text-danger">主演 :
                                    <% result.movie.casts.forEach(item=>{ %>
                                    <span><%- item.name %></span>
                                    <% }) %>
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class="text-success" style="padding-bottom:10px;padding-top:10px;"> 主内容: <%- result.content %>
                    </div>
                    <div>
                        <h6>网友回复:</h6>
                        <% result.answer && result.answer.forEach(item=>{ %>
                        <div style="display: flex;justify-content: space-between;">
                            <p class=" text-warning"> # <%- item.id*1 +1 %> </p>
                            <p> 来自:<%-  item.author?item.author :'佚名' %> </p>
                        </div>
                        <div
                            style="display: flex;justify-content: space-between;border-bottom:1px dashed red;padding-bottom:5px">
                            <p class=" text-danger"> 内容 : <%- item.subtitle %> </p>
                            <p class=" text-warning"> 时间 : <%- item.time %> </p>
                        </div>
                        <% }) %>
                    </div>
                </div>
            </div>
            <div class="col-md-6 col-sm-6 col-lg-6">
                <h2 class="text-success text-center">回复评论</h2>
                <div class="form-group">
                    <label for="answer">回复评论</label>
                    <input id="answer" name="answer" type="text" class="form-control" placeholder="请输入回复内容">
                </div>
                <div class="form-group">
                    <button type="button" data-id="<%- result._id %>" class="btn btn-success" id="submitbtn">回复</button>
                </div>
            </div>
        </div>

    </div>

    <%- include foot %>
    <script>
        //提交回复
        $('#submitbtn').click(function () {
            $.ajax({
                url: '/comment/answersubmit',
                method: 'POST',
                data: {
                    _id: $(this).attr('data-id'),
                    subtitle: $("#answer").val()
                },
                success(res) {
                    console.log(res);
                    if (res.code == 200) {//返回的是标准json数据所以用此来判断成功与否
                        window.location.reload();
                    }
                }
            })
        })
        $('#thumbnail').click(function () {
            $('.shiyan').slideToggle("slow");
        })
    </script>
</body>

</html>